<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// 
//  guest_model.php
//  www.6block.com
//  
//  Created by WillLee on 2011-06-27.
//  Copyright 2011 lishuzu. All rights reserved.
// 
 
class Guest_model extends CI_Model
{
		function __construct(){
			parent::__construct();
		}
		
		function get_guest_where($where){
			if ($where) {
				$this->db->where($where);
				$query = $this->db->get('guest');
				$guest = $query->row_array();
				return $guest;
			}
			return false;
		}
		function get_guest_by_guestid($guestid){
			if ($guestid) {
				$this->db->where('guestid', $guestid);
				$query = $this->db->get('guest');
				$guest = $query->row_array();
				return $guest;
			}
			return false;	
		}
		
		function insert_guest($data){
			if ($data) {
				$this->db->insert('guest', $data);
				return $this->db->insert_id();
			}
			return false;
		}
		
		function update_guest($data){
			if (!empty($data['guestid'])) {
				$this->db->where('guestid', $data['guestid']);
				unset($data['guestid']);
				$this->db->update('guest', $data);
				return $this->db->affected_rows();
			}
			return false;
		}
		
		function is_exist($where){
			if (is_array($where)) {
				$this->db->where($where);
				return $this->db->count_all_results('guest');
			}
			return false;
		}
}
?>